#include <iostream>
#include <vector>
using namespace std;

void _MergeSort(vector<int>& v, vector<int> tmp, size_t begin, size_t end)
{
	if(begin >= end) return;
	size_t mid = begin + (end - begin) / 2;
	_MergeSort(v, tmp, begin, mid);
	_MergeSort(v, tmp, mid + 1, end);

	size_t rbegin = mid + 1, lbegin = begin;
	int i = 0;
	while (lbegin <= mid && rbegin <= end)
	{
		if(v[lbegin] < v[rbegin]) tmp[i++] = v[lbegin++];
		else tmp[i++] = v[rbegin++];
	}
	while(lbegin <= mid) tmp[i++] = v[lbegin++];
	while(rbegin <= end) tmp[i++] = v[rbegin++];
	i = 0;
	for(int j = begin; j <= end; j++) v[j] = tmp[i++];
}

void MergeSort(vector<int>& v)
{
	size_t sz = v.size();
	vector<int> tmp(sz);
	_MergeSort(v, tmp, 0, sz - 1);
}

void MergeSortNonR(vector<int>& v)
{
	size_t sz = v.size();
	vector<int> tmp(sz);
	for(int gap = 1; gap < sz; gap *= 2)
	{
		for(int t = 0; t + gap < sz; t += gap * 2)
		{
			int begin1 = t, end1 = begin1 + gap - 1;
			int begin2 = end1 + 1, end2 = begin2 + gap - 1 > sz - 1 ? sz - 1 : begin2 + gap - 1;
			int begin = begin1, j = 0;
			while(begin1 <= end1 && begin2 <= end2)
			{
				if(v[begin1] < v[begin2]) tmp[j++] = v[begin1++];
				else tmp[j++] = v[begin2++];
			}
			while(begin1 <= end1) tmp[j++] = v[begin1++];
			while(begin2 <= end2) tmp[j++] = v[begin2++];
			j = 0;
			for(int i = begin; i <= end2; i++) v[i] = tmp[j++];
		}
	}
}

//-----------------------------------------------------------------------------
#include<iostream>
#include<vector>
using namespace std;


void MergeSort(vector<int>& v, vector<int>& tmp, int l, int r, int& num)
{
    if(l >= r) return;
	int mid = l + (r - l) / 2;
	MergeSort(v, tmp, l, mid, num);
	MergeSort(v, tmp, mid + 1, r, num);

	int rbegin = mid + 1, lbegin = l;
	int i = 0, flag = 1;
	for(int j = l; j <= mid; j++)
	{
	    for(int k = r; k >= rbegin; k--)
	    {
	        if(v[j] > v[k])
	        {
	            if(flag)
	            {
	                num += (mid - l + 1) * (r - mid);
	                break;
	            }
	            num += k - rbegin + 1;
	            flag = 0;
	            break;
	        }
	        flag = 0;
	    }
	    if(flag) break;
	}
	while (lbegin <= mid && rbegin <= r)
	{
		if(v[lbegin] < v[rbegin]) tmp[i++] = v[lbegin++];
		else tmp[i++] = v[rbegin++];
	}
	while(lbegin <= mid) tmp[i++] = v[lbegin++];
	while(rbegin <= r) tmp[i++] = v[rbegin++];
	i = 0;
	for(int j = l; j <= r; j++) v[j] = tmp[i++];
}

int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    vector<int> tmp(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    int num = 0;
    MergeSort(v, tmp, 0, n - 1, num);
    cout << num;
}
